﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ScintillaNET;
using EkStudio.com.bean.xml.RootInterface;
using EkStudio.Com.UI.Interface;
using EkStudio.com.bean.xml.RootInterface.Plugin;
using EkStudio.com.bean.xml.BillMultiple;

namespace EkStudio.com.ui.unitbill.BillMultiple
{
    public partial class ParamJavaPermitForm : DevExpress.XtraEditors.XtraForm
    {

        private BillExpandJavaCodeItem java = null;

        private ProjectUnitBillInterface parentPage = null;

        private BillMultipleParamItem module = null;

        private ProjectRootPanel RootPanel = null;
        

        public ParamJavaPermitForm(BillMultipleParamItem _bean, ProjectRootPanel Root, ProjectUnitBillInterface pRoot, BillExpandJavaCodeItem code)
        {
            InitializeComponent();
            module = _bean;
            RootPanel = Root;
            parentPage = pRoot;
            java = code;
            InitForm();
        }

        private void InitForm()
        {
            #region 初始编辑器
            JScriptMemo.Margins[0].Width = 20;
            JScriptMemo.Margins[2].Type = MarginType.Symbol;
            JScriptMemo.Margins[2].Mask = Marker.MaskFolders;
            JScriptMemo.Margins[2].Sensitive = true;
            JScriptMemo.Margins[2].Width = 20;

            JScriptMemo.Markers[Marker.Folder].Symbol = MarkerSymbol.BoxPlus;
            JScriptMemo.Markers[Marker.FolderOpen].Symbol = MarkerSymbol.BoxMinus;
            JScriptMemo.Markers[Marker.FolderEnd].Symbol = MarkerSymbol.BoxPlusConnected;
            JScriptMemo.Markers[Marker.FolderMidTail].Symbol = MarkerSymbol.TCorner;
            JScriptMemo.Markers[Marker.FolderOpenMid].Symbol = MarkerSymbol.BoxMinusConnected;
            JScriptMemo.Markers[Marker.FolderSub].Symbol = MarkerSymbol.VLine;
            JScriptMemo.Markers[Marker.FolderTail].Symbol = MarkerSymbol.LCorner;

            JScriptMemo.StyleResetDefault();
            JScriptMemo.Styles[Style.Default].Font = "Consolas";
            JScriptMemo.Styles[Style.Default].Size = 10;
            JScriptMemo.StyleClearAll();


            // Configure the CPP (C#) lexer styles
            JScriptMemo.Styles[Style.Cpp.Default].ForeColor = Color.Silver;
            JScriptMemo.Styles[Style.Cpp.Comment].ForeColor = Color.FromArgb(0, 128, 0); // Green
            JScriptMemo.Styles[Style.Cpp.CommentLine].ForeColor = Color.FromArgb(0, 128, 0); // Green
            JScriptMemo.Styles[Style.Cpp.CommentLineDoc].ForeColor = Color.FromArgb(128, 128, 128); // Gray
            JScriptMemo.Styles[Style.Cpp.Number].ForeColor = Color.Olive;
            JScriptMemo.Styles[Style.Cpp.Word].ForeColor = Color.Blue;
            JScriptMemo.Styles[Style.Cpp.Word2].ForeColor = Color.Blue;
            JScriptMemo.Styles[Style.Cpp.String].ForeColor = Color.FromArgb(163, 21, 21); // Red
            JScriptMemo.Styles[Style.Cpp.Character].ForeColor = Color.FromArgb(163, 21, 21); // Red
            JScriptMemo.Styles[Style.Cpp.Verbatim].ForeColor = Color.FromArgb(163, 21, 21); // Red
            JScriptMemo.Styles[Style.Cpp.StringEol].BackColor = Color.Pink;
            JScriptMemo.Styles[Style.Cpp.Operator].ForeColor = Color.Purple;
            JScriptMemo.Styles[Style.Cpp.Preprocessor].ForeColor = Color.Maroon;
            JScriptMemo.Lexer = Lexer.Cpp;

            // Set the keywords
            JScriptMemo.SetKeywords(0, "function abstract as base break case catch checked continue default delegate do else event explicit extern false finally fixed for foreach goto if implicit in interface internal is lock namespace new null object operator out override params private protected public readonly ref return sealed sizeof stackalloc switch this throw true try typeof unchecked unsafe import virtual while");
            JScriptMemo.SetKeywords(1, "boolean var byte char class const decimal double enum float int long sbyte short static string struct uint ulong ushort void");

            #endregion


            JScriptMemo.Text = java.Content;
            JScriptMemo.Enabled = !parentPage.ReadOnly;
            BtnSubmit.Enabled = !parentPage.ReadOnly;

            Text = string.Format("参数处理脚本-{0}", module.Caption);
        }

        private void BtnSubmit_Click(object sender, EventArgs e)
        {
            java.Content = JScriptMemo.Text;
        }
    }
}